// 生产环境配置
const merge = require('webpack-merge')
const { CleanWebpackPlugin } = require('clean-webpack-plugin')
const CopyWebpackPlugin = require('copy-webpack-plugin')
const common = require('./webpack.common')

// Object.assign(), 后面覆盖前一个对象的同名属性，但是 plugins 会覆盖了公共配置的plugins
// module.exports = Object.assign({}, common, {
//   mode: 'production',
//   plugins: [
//     new CleanWebpackPlugin(),
//     new CopyWebpackPlugin(['public'])
//   ]
// })

// 可使用 webpack-merge 模块解决 Object.assign() 的覆盖问题
module.exports = merge(common, {
  mode: 'production',
  plugins: [
    new CleanWebpackPlugin(),
    new CopyWebpackPlugin(['public'])
  ]
})
